const db = require('../db/index')

exports.getFamous = (req, res) =>{
    const sqlStr = 'select * from sys_famous'
    db.query(sqlStr, (err, results) => {
        if(err) throw err
        res.send(results)
    })
}

exports.getHistoryintroduce = (req, res) =>{
    const sqlStr = 'select * from sys_historyintroduce'
    db.query(sqlStr, (err, results) => {
        if(err) throw err
        res.send(results)
    })
}

exports.getCulturalheritage = (req, res) =>{
    const sqlStr = 'select * from sys_culturalheritage'
    db.query(sqlStr, (err, results) => {
        if(err) throw err
        res.send(results)
    })
}

exports.villagehistoryList = (req, res) =>{
    const street = req.body.street || null
    let sql = ''
    console.log(street);
    if(street == null){
        sql = `select * from sys_villagehistory`
    }else {
        sql = `select * from sys_villagehistory where street = '${street}'`
    }
    db.query(sql, (err, results) => {
        if(err) throw err
        res.send(results)
    })
}
